/**
 * 
 */
package com.momosw.games.jericho.actions;

import com.momosw.games.engine.Action;
import com.momosw.games.engine.Game;
import com.momosw.games.engine.events.ActionEvent;
import com.momosw.games.engine.events.Event;
import com.momosw.games.engine.player.Player;
import com.momosw.games.engine.util.Utils;
import com.momosw.games.jericho.board.Card;
import com.momosw.games.jericho.board.WallType;

/**
 * <b>Project:</b> JerichoCardGame<br />
 * <b>Package:</b> com.momosw.games.jericho.actions<br />
 * <b>Class:</b> FeedSupplyAction.java<br />
 * <br />
 * <i>GSI 2011</i><br />
 *
 * @author Miguel Coronado (miguelcb84@gmail.com)
 * @version	Aug 17, 2011
 *
 */
public class FeedSupplyAction implements Action, ActionEvent {

    private Game game;
    private Player current;
    private Card cardUsed;
    
    /**
     * Constructo.
     * @param game
     * @param current
     */
    public FeedSupplyAction(Game game, Player current) {
        this.game = game;
        this.current = current;
        this.cardUsed = null;
    }

    /* (non-Javadoc)
     * @see com.momosw.games.engine.Action#execute(com.momosw.games.engine.Game, com.momosw.games.engine.Player)
     */
    public void execute () {
        cardUsed = (Card)current.chooseBetween(current.getHand());

        current.removeFromHand(cardUsed);
        game.addSupply(cardUsed);
        
        Utils.notifyPlayers(game, current, this);
        
    }

    /* (non-Javadoc)
     * @see com.momosw.games.engine.Action#getReadableName()
     */
    public String getReadableName() {
        return "Alimentar pila de descartes";
    }
    
    @Override
    public String toString() {
        return "FeedSupplyAction";
    }

    public Event hidePrivate() {
        return new FeedSupplyAction (game, current);
    }

    public Action getAction() {
        return this;
    }

    /**
     * The selected card if any. "Hidden-copies" of this action will have
     * no information about the card value.
     */
    public Card getCard() {
        return cardUsed;
    }

    /**
     * DrawCardActions never have associated WallTypes
     * @return null
     */
    public WallType getWallType() {
        return null;
    }

    public Player getPlayer() {
        return current;
    }

}
